﻿//测试vscode如何提交项目修改文件到码云
const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const ejs = require('ejs');
const favicon = require('serve-favicon');
const tracer = require('tracer').colorConsole();
const app = express();


//路由
var index = require('./routes/index');//引入路由
var Backstage = require('./routes/Backstage');//引入登陆路由
var BackstageUser = require('./routes/BackstageUser');//引入登陆路由
var BackstageCommodity = require('./routes/BackstageCommodity');//引入登陆路由
var BackstageOrder = require('./routes/BackstageOrder');//引入登陆路由

/**************前台网站*************** */
var website = require('./routes/website/index');//引入路由
app.use('/', website)

/**************前台网站*************** */

app.use('/index', index);//路由别名，以后对别名的请求，会跳转到分支
app.use('/Backstage', Backstage);
app.use('/BackstageUser',BackstageUser);
app.use('/BackstageCommodity',BackstageCommodity);
app.use('/BackstageOrder',BackstageOrder);


//声明静态文件
app.use(express.static(path.join(__dirname, 'templates'))); //声明templates为外部可用地址 正常存放 js img css



app.set('views', path.join(__dirname, 'templates'));  //声明模板路径。
app.engine('html', ejs.renderFile);//引擎模板
app.set('view engine', 'html'); //模板后缀
app.set('view cache', false); //不启用模板缓存




//处理页面数据 
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());


//网页图标
app.use(favicon('templates/Backstage/assets/image/10007.ico'));

tracer.info('服务已启动', `http://127.0.0.1:3000`);


app.listen(3000);